﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GOA_Client
{
    class Simulator
    {
        private Random rnd;

        private int distanceCurrent = 0;
        private int energyCurrent = 0;
        //Total seconds passed.
        private int time = 0;

        private String value;

        /**
         * Constructor
         */
        public Simulator()
        {
            rnd = new Random();
        }

        /**
         * Creates random values for all data
         */
        public String RetrieveNewValues()
        {
            value = "";

            //Pulse
            int pulse = 80 + rnd.Next(60);
            value += pulse + " ";

            //Rounds per Minute
            int rpm = 70 + rnd.Next(80);
            value += rpm + " ";

            //Speed
            int speed = 180 + rnd.Next(120);
            value += speed + " ";

            //Distance
            distanceCurrent += rnd.Next(4);
            value += distanceCurrent + " 25 ";

            //Energy
            if (rnd.Next(3) == 0)   //1 in 3 chance to add 1 to the Energy
            {
                energyCurrent++;
            }
            value += energyCurrent + " ";

            //Time
            String timeString = "";

            //Determines hours
            if (time / 60 < 10)
            {
                timeString = "0";
            }
            timeString += (time / 60) + ":";

            //Determines minutes
            if (time % 60 < 10)
            {
                timeString += "0";
            }
            timeString += (time % 60);

            //Adds one to field timer
            time++;
            value += timeString + " ";

            return value;
        }
    }
}

